
// 格式化时间 2020-07-27 12:20:30
export const formatDate = function(date, year, split) {
    split = split || '-';
    if (!date) {
        return '';
    }
    const d = new Date(date);
    if (Number.isNaN(d.getDay())) {
        return '';
    }
    let month = (d.getMonth() + 1);
    let day = d.getDate();
    let hour = d.getHours();
    let minu = d.getMinutes();
    let second = d.getSeconds();
    let format = !year ? d.getFullYear() + split : '';
    return (format + (month < 10 ? '0' + month : month) + split +
        (day < 10 ? '0' + day : day) + ' ' +
        (hour < 10 ? '0' + hour : hour) + ':' +
        (minu < 10 ? '0' + minu : minu) + ':' +
        (second < 10 ? '0' + second : second));
};

// 格式化时间 2020-07-27 格式
export const formatDateYMD = function(date, split) {
    const fmt = formatDate(date, false, split);
    if (!fmt) return fmt;
    return fmt.substring(0, 10);
};

// 空
export const isEmpty = function(data) {
	return data === undefined || data === null || data === '' ||
		(Array.isArray(data) && data.length === 0) ||
		(typeof data === 'object' && Object.keys(data).length === 0);
}